package mapred;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class AntBuilder {

	public static void buildXML(Class<?> cls) throws IOException {
		String className = cls.getSimpleName();
		String classPath = cls.getName();
		BufferedReader br = new BufferedReader(new InputStreamReader(
				AntBuilder.class.getResourceAsStream("/build.xml")));
		BufferedWriter bw = new BufferedWriter(new FileWriter(className + ".xml"));
		for (String line = br.readLine(); line != null; line = br.readLine()) {
			bw.write(line.replaceAll("@classname@", className).replaceAll(
					"@classpath@", classPath));
			bw.newLine();
		}
		bw.flush();
		bw.close();
		br.close();
	}

}
